<!-- @format -->

<template>
  <!-- 个人中心 -->
  <div class="personal-section">
    <div class="top-box">
      <div class="left">
        <img class="img" src="@/assets/icons/index/person-center.png" alt=""/>
        <span class="title">个人中心</span>
      </div>
      <div class="more" @click="goTo('/user/profile')">
	      详情<el-icon style="margin-left: -2px"><ArrowRight /></el-icon>
      </div>
    </div>

    <div class="content-box">
	    <img class="img" v-show="state.user.userName" :src="state.user.avatar || defAva" alt=""/>
      <div class="content" v-show="state.user.userName">
        <p class="welcome">你好，{{ state.user.nickName }}</p>
        <p class="position">岗位：{{ state.postGroup }}</p>
        <p class="dept">部门：{{ deptName(state.user.deptId) }}</p>
      </div>
    </div>
  </div>
</template>

<script setup>
import defAva from "@/assets/images/profile.png";

import {getUserProfile} from "@/api/sys/user.js";

const {proxy} = getCurrentInstance();
const state = reactive({
	user: {},
	roleGroup: {},
	postGroup: {}
});

getUserProfile().then(response => {
	state.user = response.data;
	state.roleGroup = response.roleGroup;
	state.postGroup = response.postGroup;
});

function goTo(url) {
  proxy.$router.push({path: `${url}`});
};
</script>

<style lang="scss" scoped>
.personal-section {
  padding-bottom: 20px;
  background-color: #fff;
  border-radius: 6px;
  .top-box {
    display: flex;
    justify-content: space-between;
    padding: 20px 23px;
    align-items: center;
    .left {
      display: flex;
      align-items: center;
      gap: 10px;
      .img {
        width: 20px;
        height: 22px;
      }
      .title {
        color: #333333;
        font-weight: 600;
      }
    }
    .more {
      display: flex;
      align-items: center;
      font-size: 12px;
      color: #a5a8ab;
      letter-spacing: 1px;
      cursor: pointer;
      transition: all 100ms;
      &:hover {
        color: #3d7fff;
      }
    }
  }
  .content-box {
    margin: 0px 23px;
    padding: 15.5px 20px;
    background: linear-gradient(0deg, #e7f2ff, #c8deff);
    display: flex;
    gap: 19px;
    border-radius: 6px;
    height: 151px;
    transition: all 200ms;
    &:hover {
      transform: translateY(-0.5px);
      box-shadow: 0 6px 12px rgba(#000, 0.04);
      background: linear-gradient(0deg, #e0ecfb, #c4dcfe);
    }
    .img {
      width: 120px;
      height: 120px;
      border: 3px solid #ffffff;
      transition: all 300ms;
    }
    .content {
      transition: all 300ms;

      .welcome {
        font-size: 20px;
        color: #333333;
        margin: 0;
        margin-top: 7px;
      }
      .position {
        margin: 0;
        margin-top: 18px;
        font-size: 16px;
        color: #333333;
      }
      .dept {
        margin: 0;
        margin-top: 10px;
        font-size: 16px;
        color: #333333;
      }
    }
  }
}
</style>
